package com.icoolkj.mall.user.openfeign.demo.controller;

import com.icoolkj.mall.common.Result;
import com.icoolkj.mall.user.openfeign.demo.feign.OrderFeignService;
import com.icoolkj.mall.user.openfeign.demo.feign.dto.OrderRequest;
import com.icoolkj.mall.user.openfeign.demo.feign.dto.OrderResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author icoolkj
 * @version 1.0
 * @description
 * @createDate 2025/01/20 15:51
 */
@Slf4j
@RestController
@RequestMapping("/api/user")
public class UserController {

    @Autowired
    private OrderFeignService orderFeignService;

    @RequestMapping(value = "/getOrderByUserId")
    public Result<List<OrderResponse>> getOrderByUserId(@RequestParam("userId") Long userId) {
        log.info("根据userId：{} 查询订单信息", userId);
        //使用openFeign调用订单服务
        Result<List<OrderResponse>> result = orderFeignService.getOrderByUserId(userId);
        return result;
    }


//    @RequestMapping(value = "/post1")
//    public Result<OrderResponse> post1(@RequestBody OrderRequest orderRequest) {
//        log.info("根据 order：{} 插入订单", orderRequest);
//        //使用openFeign调用订单服务
//        Result<OrderResponse> result = orderFeignService.post1(orderRequest);
//        return result;
//    }
//
//    @RequestMapping(value = "/post2")
//    public Result<OrderResponse> post2(@RequestBody OrderRequest orderRequest, @RequestParam("token") String token) {
//        log.info("根据 order：{} 插入订单， token：{}", orderRequest, token);
//        //使用openFeign调用订单服务
//        Result<OrderResponse> result = orderFeignService.post2(orderRequest, token);
//        return result;
//    }
//
//    @RequestMapping(value = "/post3/{userId}")
//    public Result<OrderResponse> post3(@RequestBody OrderRequest orderRequest, @PathVariable("userId") Long userId) {
//        log.info("根据 order：{} 插入订单， userId：{}", orderRequest, userId);
//        //使用openFeign调用订单服务
//        Result<OrderResponse> result = orderFeignService.post3(orderRequest, userId);
//        return result;
//    }

}
